/**
 * Created by xxx on 2017/6/13.
 * 移动端登录
 */

var Main = React.createClass({
    onClickLogin: function () {
        var userName = $("input[type='text']").val(),userPwd = $("input[type='password']").val();
        if(userName == ""){
            suixun.tips("用户名不能为空!");
            return;
        }
        if(userPwd == ""){
            suixun.tips("密码不能为空!");
            return;
        }else if(userPwd.length < 6){
            suixun.tips("密码格式错误!");
            return;
        }
        if($(".loginButton").html() == "登录"){
            $(".loginButton").html("登录中...");
            suixun.ajax(serverUrl+'/userManager/loginService.json','param={"account":"'+userName+'","password":"'+userPwd+'"}',"get",function(data){
                if(data.code==200){
                    localStorage.userName = userName;
                    window.location.href = '../statManager/mobile-statList.html';//去统计查询
                }else{
                    $(".loginButton").html("登录");
                    suixun.alert(data.msg);
                }
            });
        }

    },
    render: function () {
        return (
            <div className="statList">
                <header>
                    <div className="title">账户登录</div>
                </header>
                <div className="body">
                    <div className="blank"></div>
                    <div className="info">
                        <div className="user-info">
                            <div className="img"><img src="../img/icon/mobile/userNumber.png" /></div>
                            <div className="content"><input type="text" id="userNumber" placeholder='请输入账号' maxLength="20" /></div>
                        </div>
                        <div className="user-info" style={{top:'11px'}}>
                            <div className="img"><img src="../img/icon/mobile/password.png" /></div>
                            <div className="content"><input type="password" id="password" placeholder='请输入密码' maxLength="20" /></div>
                        </div>
                        <div className="loginButton" onClick={this.onClickLogin}>登录</div>
                    </div>
                </div>
            </div>
        );
    }
});
ReactDOM.render(
    <Main  />,
    document.getElementById('app')
);

